package com.zlyx.easy.core.tool;

import java.util.Collection;
import java.util.Map;

import com.zlyx.easy.core.list.Lists;
import com.zlyx.easy.core.map.Maps;

public final class Empty {

	private static final String EMPTY = "";

	public static boolean isEmpty(Object o) {
		return Null.isNull(o) || EMPTY.equals(o);
	}

	public static boolean isNotEmpty(Object o) {
		return !isEmpty(o);
	}

	@SuppressWarnings("unchecked")
	public static <E> boolean isEmpty(E... es) {
		return Null.isNull(es) || es.length == 0;
	}

	@SuppressWarnings("unchecked")
	public static <E> boolean isNotEmpty(E... es) {
		return !isEmpty(es);
	}

	public static boolean isEmpty(Collection<?> c) {
		return Null.isNull(c) || c.size() == 0;
	}

	public static boolean isNotEmpty(Collection<?> c) {
		return !isEmpty(c);
	}

	public static boolean isEmpty(Map<?, ?> m) {
		return Null.isNull(m) || m.size() == 0;
	}

	public static boolean isNotEmpty(Map<?, ?> m) {
		return !isEmpty(m);
	}

	public static void main(String[] args) {
		System.out.println(Empty.isEmpty(""));
		System.out.println(Empty.isEmpty(1));
		System.out.println(Empty.isEmpty(1, 2));
		System.out.println(Empty.isEmpty(Lists.newList()));
		System.out.println(Empty.isEmpty(Lists.newList(1, 2)));
		System.out.println(Empty.isEmpty(Maps.newMap()));
		System.out.println(Empty.isEmpty(Maps.newMap(1, 2)));
		
		System.out.println(Empty.isNotEmpty(""));
		System.out.println(Empty.isNotEmpty(1));
		System.out.println(Empty.isNotEmpty(1, 2));
		System.out.println(Empty.isNotEmpty(Lists.newList()));
		System.out.println(Empty.isNotEmpty(Lists.newList(1, 2)));
		System.out.println(Empty.isNotEmpty(Maps.newMap()));
		System.out.println(Empty.isNotEmpty(Maps.newMap(1, 2)));
	}
}
